package com.jwsoft.manager.core.gateway.controller.common;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.common.pdfSignRequest.PdfSignRequestKeyVO;
import com.jwsoft.manager.common.vo.common.pdfSignRequest.PdfSignRequestQueryVO;
import com.jwsoft.manager.common.vo.common.pdfSignRequest.PdfSignRequestVO;
import com.jwsoft.manager.core.integration.common.PdfSignRequestIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * PDF签章请求模板表网关
 *
 * @author zhang
 * @since 2025-02-06
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "PDF签章请求模板表", description = "PDF签章请求模板表")
public class PdfSignRequestController {

    @Autowired
    public PdfSignRequestIntegration pdfSignRequestIntegration;

    @Operation(summary = "PDF签章请求模板表分页查询",description = "PDF签章请求模板表分页查询")
    @PostMapping(value = "/pdfSignRequest0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<PdfSignRequestVO>> getList(@RequestBody @Validated PdfSignRequestQueryVO vo) {
        return AppResponse.successData(pdfSignRequestIntegration.getList(vo));
    }

    @Operation(summary = "PDF签章请求模板表根据主键查询详情",description = "PDF签章请求模板表根据主键查询详情")
    @PostMapping(value = "/pdfSignRequest0002", produces = "application/json;charset=UTF-8")
    public AppResponse<PdfSignRequestVO> getById(@RequestBody @Validated PdfSignRequestKeyVO vo) {
        return AppResponse.successData(pdfSignRequestIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "PDF签章请求模板表新增",description = "PDF签章请求模板表新增")
    @PostMapping(value = "/pdfSignRequest0004", produces = "application/json;charset=UTF-8")
    public AppResponse<PdfSignRequestVO> add(@RequestBody @Validated(value = {Validators.Add.class}) PdfSignRequestVO vo) {
        return AppResponse.successData(pdfSignRequestIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "PDF签章请求模板表修改",description = "PDF签章请求模板表修改")
    @PostMapping(value = "/pdfSignRequest0005", produces = "application/json;charset=UTF-8")
    public AppResponse<PdfSignRequestVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) PdfSignRequestVO vo) {
        return AppResponse.successData(pdfSignRequestIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "PDF签章请求模板表删除",description = "PDF签章请求模板表删除")
    @PostMapping(value = "/pdfSignRequest0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated PdfSignRequestKeyVO vo) {
        pdfSignRequestIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "PDF签章请求公共接口",description = "PDF签章请求公共接口")
    @PostMapping(value = "/pdfSignRequest0007", produces = "application/json;charset=UTF-8")
    public AppResponse getSignRequest(@RequestBody @Validated PdfSignRequestVO vo) {
        pdfSignRequestIntegration.getSignRequest(vo);
        return AppResponse.successMsg("操作成功！");
    }
}
